package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbeoo.
 */
@Configurable
@Entity
@Table(name = "TTLSBEOO",schema = "TLSB")
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbeooPK.class, versionField = "",  persistenceUnit="persistenceUnitTLSB",table = "TTLSBEOO", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLSB")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbeoo {

	/** The des campoord. */
	@Column(name = "DES_CAMPOORD", columnDefinition = "CHAR", length = 100)
    @NotNull
    private String desCampoord;

	/** The cod sepa. */
	@Column(name = "COD_SEPA", columnDefinition = "CHAR")
    @NotNull
    private Character codSepa;

	/** The des campolar. */
	@Column(name = "DES_CAMPOLAR", columnDefinition = "CHAR", length = 40)
    @NotNull
    private String desCampolar;

	/** The xti tipocam. */
	@Column(name = "XTI_TIPOCAM", columnDefinition = "CHAR")
    @NotNull
    private Character xtiTipocam;

	/** The xsn campopci. */
	@Column(name = "XSN_CAMPOPCI", columnDefinition = "CHAR")
    @NotNull
    private Character xsnCampopci;

	/** The des valopci. */
	@Column(name = "DES_VALOPCI", columnDefinition = "VARCHAR", length = 50)
    private String desValopci;

	/** The xsn encadena. */
	@Column(name = "XSN_ENCADENA", columnDefinition = "CHAR")
    @NotNull
    private Character xsnEncadena;

	/** The des encadena. */
	@Column(name = "DES_ENCADENA", columnDefinition = "CHAR")
    private Character desEncadena;

	/** The des coleccio. */
	@Column(name = "DES_COLECCIO", columnDefinition = "CHAR", length = 60)
    private String desColeccio;

	/** The xsn oculto. */
	@Column(name = "XSN_OCULTO", columnDefinition = "DECIMAL")
    @NotNull
    private BigDecimal xsnOculto;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO", columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/**
	 * Gets the des campoord.
	 *
	 * @return the des campoord
	 */
	public String getDesCampoord() {
        return this.desCampoord;
    }

	/**
	 * Sets the des campoord.
	 *
	 * @param desCampoord the new des campoord
	 */
	public void setDesCampoord(String desCampoord) {
        this.desCampoord = desCampoord;
    }

	/**
	 * Gets the cod sepa.
	 *
	 * @return the cod sepa
	 */
	public Character getCodSepa() {
        return this.codSepa;
    }

	/**
	 * Sets the cod sepa.
	 *
	 * @param codSepa the new cod sepa
	 */
	public void setCodSepa(Character codSepa) {
        this.codSepa = codSepa;
    }

	/**
	 * Gets the des campolar.
	 *
	 * @return the des campolar
	 */
	public String getDesCampolar() {
        return this.desCampolar;
    }

	/**
	 * Sets the des campolar.
	 *
	 * @param desCampolar the new des campolar
	 */
	public void setDesCampolar(String desCampolar) {
        this.desCampolar = desCampolar;
    }

	/**
	 * Gets the xti tipocam.
	 *
	 * @return the xti tipocam
	 */
	public Character getXtiTipocam() {
        return this.xtiTipocam;
    }

	/**
	 * Sets the xti tipocam.
	 *
	 * @param xtiTipocam the new xti tipocam
	 */
	public void setXtiTipocam(Character xtiTipocam) {
        this.xtiTipocam = xtiTipocam;
    }

	/**
	 * Gets the xsn campopci.
	 *
	 * @return the xsn campopci
	 */
	public Character getXsnCampopci() {
        return this.xsnCampopci;
    }

	/**
	 * Sets the xsn campopci.
	 *
	 * @param xsnCampopci the new xsn campopci
	 */
	public void setXsnCampopci(Character xsnCampopci) {
        this.xsnCampopci = xsnCampopci;
    }

	/**
	 * Gets the des valopci.
	 *
	 * @return the des valopci
	 */
	public String getDesValopci() {
        return this.desValopci;
    }

	/**
	 * Sets the des valopci.
	 *
	 * @param desValopci the new des valopci
	 */
	public void setDesValopci(String desValopci) {
        this.desValopci = desValopci;
    }

	/**
	 * Gets the xsn encadena.
	 *
	 * @return the xsn encadena
	 */
	public Character getXsnEncadena() {
        return this.xsnEncadena;
    }

	/**
	 * Sets the xsn encadena.
	 *
	 * @param xsnEncadena the new xsn encadena
	 */
	public void setXsnEncadena(Character xsnEncadena) {
        this.xsnEncadena = xsnEncadena;
    }

	/**
	 * Gets the des encadena.
	 *
	 * @return the des encadena
	 */
	public Character getDesEncadena() {
        return this.desEncadena;
    }

	/**
	 * Sets the des encadena.
	 *
	 * @param desEncadena the new des encadena
	 */
	public void setDesEncadena(Character desEncadena) {
        this.desEncadena = desEncadena;
    }

	/**
	 * Gets the des coleccio.
	 *
	 * @return the des coleccio
	 */
	public String getDesColeccio() {
        return this.desColeccio;
    }

	/**
	 * Sets the des coleccio.
	 *
	 * @param desColeccio the new des coleccio
	 */
	public void setDesColeccio(String desColeccio) {
        this.desColeccio = desColeccio;
    }

	/**
	 * Gets the xsn oculto.
	 *
	 * @return the xsn oculto
	 */
	public BigDecimal getXsnOculto() {
        return this.xsnOculto;
    }

	/**
	 * Sets the xsn oculto.
	 *
	 * @param xsnOculto the new xsn oculto
	 */
	public void setXsnOculto(BigDecimal xsnOculto) {
        this.xsnOculto = xsnOculto;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/** The entity manager. */
//	@PersistenceContext
	@PersistenceContext(unitName="persistenceUnitTLSB")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsbeooPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsbeooPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsbeooPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlsb")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlsb")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbeoo attached = Ttlsbeoo.findTtlsbeoo(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlsb")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlsb")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbeoo
	 */
	@Transactional(value="tlsb")
    public Ttlsbeoo merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbeoo merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbeoo().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbeoos.
	 *
	 * @return the long
	 */
	@Transactional(value="tlsb")
	public static long countTtlsbeoos() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbeoo o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbeoos.
	 *
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbeoo> findAllTtlsbeoos() {
        return entityManager().createQuery("SELECT o FROM Ttlsbeoo o", Ttlsbeoo.class).getResultList();
    }

	
	/**
	 * Find ttlsbeoo.
	 *
	 * @param id the id
	 * @return the ttlsbeoo
	 */
	@Transactional(value="tlsb")
	public static Ttlsbeoo findTtlsbeoo(TtlsbeooPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbeoo.class, id);
    }

	
	/**
	 * Find ttlsbeoo entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbeoo> findTtlsbeooEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbeoo o", Ttlsbeoo.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodSepa: ").append(getCodSepa()).append(", ");
        sb.append("DesCampolar: ").append(getDesCampolar()).append(", ");
        sb.append("DesCampoord: ").append(getDesCampoord()).append(", ");
        sb.append("DesColeccio: ").append(getDesColeccio()).append(", ");
        sb.append("DesEncadena: ").append(getDesEncadena()).append(", ");
        sb.append("DesValopci: ").append(getDesValopci()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("XsnCampopci: ").append(getXsnCampopci()).append(", ");
        sb.append("XsnEncadena: ").append(getXsnEncadena()).append(", ");
        sb.append("XsnOculto: ").append(getXsnOculto()).append(", ");
        sb.append("XtiTipocam: ").append(getXtiTipocam());
        return sb.toString();
    }
}
